#ifdef FSHIGHPRECISION
	precision highp float;
#else
	precision mediump float;
#endif

varying vec2 v_Texcoord0;
varying vec2 v_Texcoord1;

#ifdef MAINTEXTURE
	uniform sampler2D u_MainTexture;
#endif

#ifdef MASKTEXTURE
	uniform sampler2D u_MaskTexture;
#endif

uniform vec4 u_BaseColor;
uniform vec4 u_AlphaColor;
uniform float u_Instensity;
uniform float u_Alpha;

void main()
{
	vec4 mainTextureColor = vec4(1.0);
	#ifdef MAINTEXTURE
		mainTextureColor = texture2D(u_MainTexture, v_Texcoord0);
	#endif
	
	vec4 maskTextureColor = vec4(1.0);
	#ifdef MASKTEXTURE
		maskTextureColor = texture2D(u_MaskTexture, v_Texcoord1);
	#endif
	
	vec4 outColor = mix(vec4(0.0), mainTextureColor, maskTextureColor);
	
	gl_FragColor = 2.0 * outColor * u_BaseColor * u_AlphaColor * u_Instensity;
	gl_FragColor.a *= u_Alpha;
}
